from time import *

class Loading:

    def __init__(self, init_string = "Starting ", end_string = " done") -> None:
        self.init_string = init_string
        self.end_string = end_string
        self.output = ""
    
    def _loadPencent(self, pencent) -> None:
        self.output = self.init_string
        if pencent > 100:
            pencent = 100
        for i in range(pencent//5):
            self.output += "."
        if pencent == 100:
            self.output = self.output + self.end_string + "\n"

    def show(self, percent) -> None:
        self.nowoutput = self.output
        self._loadPencent(percent)
        if not (self.output == self.nowoutput):
            print(self.output,end="\r")

    def __str__(self) -> str:
        return self.output
    
loading = Loading()
# loading._loadPencent(100)
for i in range(100):
    sleep(0.1)
    loading.show(i+1)

# print(loading)

